# ----------------------------------------------------------------------
# Copyright (C) 2013 - 2014: Sergey Smolyannikov <brainstream@yandex.com>
#
# This file is part of lxpamon.
#
# lxpamon is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# lxpamon is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with lxpamon. If not, see http://www.gnu.org/licenses/gpl-3.0.txt.
# ----------------------------------------------------------------------

cmake_minimum_required(VERSION 2.8)
include(FindPkgConfig)

project(lxpamon)

set(LIBNAME ${CMAKE_PROJECT_NAME})
set(EXENAME pamon)

list(APPEND CMAKE_C_FLAGS "-std=gnu99")

set(SRC_DIR src)

set(COMMON_SRC
    ${SRC_DIR}/pamon.h
    ${SRC_DIR}/pamon.c
    ${SRC_DIR}/utils.h
    ${SRC_DIR}/utils.c
)
set(LIB_SRC
    ${COMMON_SRC}
    ${SRC_DIR}/lxpamon.c
)
set(EXE_SRC
    ${COMMON_SRC}
    ${SRC_DIR}/main.c
)

pkg_check_modules(GTK2 REQUIRED gtk+-2.0)
pkg_check_modules(LXPANEL REQUIRED lxpanel)
pkg_check_modules(PULSE REQUIRED libpulse)
pkg_check_modules(PULSEML REQUIRED libpulse-mainloop-glib)

include_directories(
    ${GTK2_INCLUDE_DIRS}
    ${LXPANEL_INCLUDE_DIRS}
    ${PULSE_INCLUDE_DIRS}
    ${PULSEML_INCLUDE_DIRS}
)
set(LIBRARIES
    ${GTK2_LIBRARIES}
    ${LXPANEL_LIBRARIES}
    ${PULSE_LIBRARIES}
    ${PULSEML_LIBRARIES}
    -lm
)

add_library(${LIBNAME} SHARED ${LIB_SRC})
target_link_libraries(${LIBNAME} ${LIBRARIES})
set_target_properties(${CMAKE_PROJECT_NAME} PROPERTIES PREFIX "")
add_executable(${EXENAME} ${EXE_SRC})
target_link_libraries(${EXENAME} ${LIBRARIES})

install(TARGETS ${LIBNAME} DESTINATION ${LXPANEL_LIBDIR}/lxpanel/plugins)
